package segger.vasttrafik.io;

import java.io.IOException;
import java.net.MalformedURLException;

import javax.xml.parsers.ParserConfigurationException;

import org.apache.log4j.Logger;
import org.xml.sax.SAXException;

import segger.vasttrafik.parsing.XMLParseHandler;

public class APIConnection {
    private static final Logger logger = Logger.getLogger(APIConnection.class);
    
    public void httpGet(String url, XMLParseHandler handler) {
        try {
            /*String response = HttpConnection.get(url);
            XMLParser.parse(response, handler);*/
            HttpConnection.getParsedReponse(url, handler);
        } catch (MalformedURLException e) {
            logger.error("url is not correct: " + url + " [" + e.getMessage() + "]");
        } catch (IOException e) {
            logger.error("could not connect to " + url + "[" + e.getMessage() + "]");
        } catch (ParserConfigurationException e) {
            logger.error("could not parse response [" + e.getMessage() + "]");
        } catch (SAXException e) {
            logger.error("xml format could not be parsed [" + e.getMessage() + "]");
        }
    }
}
